import Icon from '@/components/Icon'
import styles from './index.module.scss'
import { useHistory } from 'react-router-dom';
import classNames from 'classnames';
function Navbar({ children, extra, navbarAction, type, className }) {
    const history = useHistory()
    const goBack = () => {
        if (navbarAction) {
            navbarAction(type)
        } else {
            history.go(-1)
        }
    }
    return (
        <div className={classNames(styles.root, className)}>
            {/* 后退按钮 */}
            <div className="left">
                <Icon type="iconfanhui" onClick={goBack} />
            </div>
            {/* 居中标题 */}
            <div className="title">{children}</div>

            {/* 右侧内容 */}
            <div className="right">{extra}</div>
        </div>
    )
}


export default Navbar